﻿<%@ Page Language="C#" MasterPageFile="~/Default.Master" AutoEventWireup="true" CodeBehind="Presentation.aspx.cs"
    Inherits="Kiosk.WebManagement.Presentation" Title="Manage Slide Show" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<%@ Register Assembly="Csla" Namespace="Csla.Web" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

    <script type="text/javascript" language="javascript">
        function openSlideEditor(slideID)
        {
            window.open("EditSlide.aspx?slideID=" + slideID, "Edit Slide",
            "height=735,width=800,status=0,menubar=0,resizable=0");            
            return false;
        }
    </script>

    <style type="text/css">
        .style1
        {
            width: 40%;
        }
        .AddPresentation
        {
            margin: 0px 0px 0px 50px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="content" runat="server">
    <ajaxToolkit:ToolkitScriptManager runat="server" ID="scriptManager" />
<%--    <asp:UpdatePanel runat="server" ID="updatepanel1">
        <ContentTemplate>--%>
            <cc1:CslaDataSource ID="PresentationsDatasource" runat="server" TypeAssemblyName=""
        TypeName="Kiosk.Library.PresentationReadOnlyList, Kiosk.Library" TypeSupportsPaging="False"
        TypeSupportsSorting="False" OnSelectObject="PresentationsDatasource_SelectObject">
    </cc1:CslaDataSource>
    <cc1:CslaDataSource ID="PresTypeDS" runat="server" TypeAssemblyName="" TypeName="Kiosk.Library.PresentationTypeReadOnlyList, Kiosk.Library"
        TypeSupportsPaging="False" TypeSupportsSorting="False" OnSelectObject="PresTypeDS_SelectObject">
    </cc1:CslaDataSource>
    <cc1:CslaDataSource ID="PresStatusDS" runat="server" TypeAssemblyName="" TypeName="Kiosk.Library.PresentationStatusReadOnlyList, Kiosk.Library"
        TypeSupportsPaging="False" TypeSupportsSorting="False" OnSelectObject="PresStatusDS_SelectObject">
    </cc1:CslaDataSource>
    <cc1:CslaDataSource ID="SlidesDataSource" runat="server" TypeAssemblyName="" TypeName="Kiosk.Library.SlideReadOnlyList, Kiosk.Library"
        TypeSupportsPaging="False" TypeSupportsSorting="False" OnSelectObject="SlidesDataSource_SelectObject">
    </cc1:CslaDataSource>

            <div class="TopContent">
                &nbsp;</div>
            <div class="MiddleContent">
                <table style="width:90%; margin: 0px 0px 0px 50px;">
                    <tr>
                        <td class="style1">
                            <asp:GridView ID="grdPresentations" runat="server" AutoGenerateColumns="False" DataSourceID="PresentationsDatasource"
                                OnRowDeleting="grdPresentations_RowDeleting"  
                                DataKeyNames="PresentationID" OnSelectedIndexChanged="grdPresentations_SelectedIndexChanged"
                                CellPadding="4" ForeColor="#333333" GridLines="None" 
                                onrowcommand="grdPresentations_RowCommand" 
                                onrowcreated="grdPresentations_RowCreated" >
                                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                                <Columns>
                                    <asp:CommandField ButtonType="Image" HeaderText="" SelectImageUrl="~/images/icons/resultset_next.png"
                                        ShowSelectButton="True"></asp:CommandField>
                                    <asp:ButtonField ButtonType="Image" CommandName="EditPres"
                                        ImageUrl="~/images/icons/page_edit.png" Text="Edit" />
                                    <asp:BoundField DataField="Name" HeaderText="Presentation Name" ReadOnly="True" SortExpression="Name" />
                                    <asp:BoundField DataField="PresentationTypeName" HeaderText="Type" ReadOnly="True"
                                        SortExpression="PresentationTypeName" />
                                    <asp:BoundField DataField="PresentationStatusName" HeaderText="Status" SortExpression="PresentationStatusName" />
                                    <asp:CommandField ButtonType="Image" DeleteImageUrl="~/images/icons/delete.png" 
                                        ShowDeleteButton="True" />
                                </Columns>
                                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                                <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                                <HeaderStyle BackColor="#3c3c3c" Font-Bold="True" ForeColor="White" />
                                <EditRowStyle BackColor="#999999" />
                                <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                            </asp:GridView>
                        </td>
                        <td style="width: 40%;">
                            <ajaxToolkit:ReorderList ID="slideList" runat="server" Visible="false" DataSourceID="SlidesDataSource"
                                DragHandleAlignment="Left" ItemInsertLocation="End" DataKeyField="SlideID" SortOrderField="Order"
                                AllowReorder="true" OnItemReorder="slideList_ItemReorder" OnItemDataBound="slideList_ItemDataBound"
                                OnInsertCommand="slideList_InsertCommand" CssClass="reorderList">
                                <EmptyListTemplate>
                                    Sorry, this presentation has no slides.
                                </EmptyListTemplate>
                                <ItemTemplate>
                                    <table>
                                        <tr>
                                            <td style="width: 200px">
                                                <%# Eval("Title") %>
                                            </td>
                                            <td>
                                                <asp:HyperLink ID="editLink" onclick='return openSlideEditor("{0}");' runat="server"
                                                    Target="_blank" NavigateUrl='EditSlide.aspx?slideID={0}' ImageUrl="images/icons/image_edit.png"></asp:HyperLink>
                                            </td>
                                            <td>
                                                <asp:ImageButton ID="deleteSlide" runat="server" OnClientClick='return confirm("Do you wish to delete this slide");'
                                                    ImageUrl="images/icons/image_delete.png" CommandName="Delete" CommandArgument='<%# Eval("SlideID") %>'
                                                    OnCommand="deleteSlide_Command" />
                                            </td>
                                        </tr>
                                    </table>
                                </ItemTemplate>
                                <InsertItemTemplate>
                                    <br />
                                    Add a Slide:
                                    <asp:TextBox Width="135px" ID="txtNewSlide" runat="server"></asp:TextBox>
                                    <asp:Button BorderStyle="Ridge" Width="50px" ID="btnAdd" runat="server" CommandName="Insert"
                                        Text="Add" BackColor="#3c3c3c" ForeColor="White" />
                                </InsertItemTemplate>
                                <DragHandleTemplate>
                                    <div class="dragHandle">
                                        <img alt="reorder" src="images/icons/arrow_switch.png" />
                                    </div>
                                </DragHandleTemplate>
                                <EditItemTemplate>
                                </EditItemTemplate>
                                <ReorderTemplate>
                                    <div class="reorderItem">
                                        <%# Eval("Title") %>
                                    </div>
                                </ReorderTemplate>
                            </ajaxToolkit:ReorderList>
                            <asp:Panel ID="pnlVideoSelector" runat="server" >
                                Please select a video (or upload one in the <br /> File Manager): <br />
                                <asp:DropDownList ID="ddVideo" runat="server" Width="143px">
                                </asp:DropDownList>
                                &nbsp;
                                <asp:Button ID="btnChangeVideo" runat="server" onclick="btnChangeVideo_Click" 
                                    Text="Change Video" />
                            
                            </asp:Panel>
                        </td>
                    </tr>
                </table>
                <asp:Button CssClass="AddPresentation" ID="btnAdd0" runat="server" OnClick="btnAdd_Click"
                    Text="Add Presentation" />
            </div>
            <div class="BottomContent">
                &nbsp;</div>
                <br /> <br />
                            <asp:Panel runat="server" ID="pnlAdd">
                <div class="TopContent">
                    &nbsp;</div>
                <div class="MiddleContent">
                    <table style="margin: 0px 0px 0px 50px;">
                        <tr>
                            <td>
                                Presentation Name:
                            </td>
                            <td>
                                <asp:TextBox ID="txtName" runat="server"></asp:TextBox><asp:RequiredFieldValidator
                                    ID="RequiredFieldValidator1" runat="server" ErrorMessage="Presentation Name is required"
                                    ControlToValidate="txtName"></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Presentation Type:
                            </td>
                            <td>
                                <asp:DropDownList ID="ddType" runat="server" DataSourceID="PresTypeDS" DataTextField="Name"
                                    DataValueField="PresentationTypeID">
                                </asp:DropDownList>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Presentation Status:
                            </td>
                            <td>
                                <asp:DropDownList ID="ddStatus" runat="server" DataSourceID="PresStatusDS" DataTextField="Name"
                                    DataValueField="PresentationStatusID">
                                </asp:DropDownList>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" />
                                <asp:Button ID="btnCancel" CausesValidation="false" runat="server" Text="Cancel" OnClick="btnCancel_Click" />
                            </td>
                        </tr>
                    </table>
                </div>
                <div class="BottomContent">
                    &nbsp;</div>
            </asp:Panel>
    <%# Eval("Title") %> 
</asp:Content>
